import { URI } from "@/services/api";
import { request, METHOD } from "@/utils/request";

export async function getData(type, docType, status, docNum, supplierCode, pageSize, pageIndex) {
    return request(`${URI}/Order/GetData`, METHOD.GET, { type, docType, status, docNum, supplierCode, pageSize, pageIndex });
}

export async function getItemData(type, docNum, supplierCode, pageSize, pageIndex) {
    return request(`${URI}/Order/GetItemData`, METHOD.GET, { type, docNum, supplierCode, pageSize, pageIndex });
}

export async function getReturnItemData(docNum, labelId, pageSize, pageIndex) {
    return request(`${URI}/Order/GetReturnItemData`, METHOD.GET, { docNum, labelId, pageSize, pageIndex });
}

export async function GetDetailItems(type, docNum, pageSize, pageIndex) {
    return request(`${URI}/Order/GetDetailItems`, METHOD.GET, { type, docNum, pageSize, pageIndex });
}

export async function getTask(type, docType, status, docNum, labelId, pageSize, pageIndex) {
    return request(`${URI}/OrderItemDetail/GetData`, METHOD.GET, { type, docType, status, docNum, labelId, pageSize, pageIndex });
}

export async function getItems(docNum) {
    return request(`${URI}/Order/GetItems`, METHOD.GET, { docNum });
}

export async function getTLOrderNum() {
    return request(`${URI}/Order/GetTLOrderNum`, METHOD.GET);
}

export async function getPickOrderDetail(docNum) {
    return request(`${URI}/Order/GetPickOrderDetail`, METHOD.GET, { docNum });
}

export async function pickReturnOrder(model) {
    return request(`${URI}/Order/PickReturnOrder`, METHOD.POST, {
        model: model,
    });
}

export async function removePick(model) {
    return request(`${URI}/Order/PickReturnOrder`, METHOD.POST, {
        model: model,
    });
}

export async function createPickData(docNum) {
    var data = { DocNum: docNum };
    return request(`${URI}/Order/CreatePickData`, METHOD.POST, data);
}

export async function PickSplit(labelId) {
    return request(`${URI}/Order/PickSplit`, METHOD.POST, { LabelId: labelId });
}

export async function batchCompleteTask(ids) {
    return request(`${URI}/Order/OrderManualComplete?ids=`+ids, METHOD.POST);
}

export default {
    getData,
    getItemData,
    getReturnItemData,
    getTask,
    getItems,
    getTLOrderNum,
    getPickOrderDetail,
    pickReturnOrder,
    batchCompleteTask,
    removePick,
    createPickData,
    PickSplit,
    GetDetailItems
};
